<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" xml:lang="pt" lang="pt-br">

<h:body>
	<p:dialog widgetVar="pesqSalaDialogWidget" id="pesqSalaDialogId"
		height="400" width="700" modal="true" closable="true"
		draggable="false" resizable="false">
		<h:form id="pesqSalaDialogForm" title="Pesquisar">
			<h:panelGrid columns="9">
				
				<h:panelGroup>
					<h:outputText value=" Dia: " />
					<p:calendar id="dia" value="#{salaManager.dia}" pattern="MM/dd/yyyy" label="Dia"
						mindate="#{salaManager.currentDate()}" required="true" size="12" locale="pt"/>
	
					<h:outputText value="Hora Inicial: " />
					<p:calendar id="inicio" value="#{salaManager.dataInicio}" size="5" label="Hora Inicial"
						pattern="HH:mm" timeOnly="true" locale="pt"/>
	
					<h:outputText value=" Hora Final: " />
					<p:calendar id="fim" value="#{salaManager.dataFim}" size="5" label="Hora Final"
						pattern="HH:mm" validator="#{salaManager.validarHora}"
						timeOnly="true" locale="pt"/>
	
					<p:commandButton value="Pesquisar" id="pesquisa"
						actionListener="#{salaManager.listarSalasDisponiveis}"
						update=":pesqSalaDialogForm :salas :msgDialog" />
					
				</h:panelGroup>
				
			</h:panelGrid>
		</h:form>
		<p:messages id="msgDialog" showDetail="false" />

		<p:dataTable id="salas" var="sala"
			value="#{salaManager.salasDisponiveis}" paginator="true" rows="10"
			selectionMode="single">

			<p:ajax event="rowSelect" listener="#{salaManager.onRowSelect}"
				oncomplete="pesqSalaDialogWidget.hide()" update=":reserva" />

			<f:facet name="header">
            		Selecione a sala para a reserva.
        		</f:facet>

			<p:column headerText="Nome">
            		#{sala.nome}
        		</p:column>

			<p:column headerText="Capacidade">
            		#{sala.capacidade}
        		</p:column>

		</p:dataTable>

	</p:dialog>
</h:body>
</html>